#include <iostream> 
#include <cstring>
using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n],b[n];
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<n; i++) cin >> b[i];
	unsigned int W[n],E[n],R[n];
	memset(W,0xFE,n*sizeof(unsigned int));
	memset(E,0xFE,n*sizeof(unsigned int));
	memset(R,0xFE,n*sizeof(unsigned int));
	if(a[0]==1) W[0] = 0;
	if(b[0]==1) E[0] = 0;
	R[0] = 1;
	for(int i=1; i<n; i++){
		if( a[i]==1 ) W[i] = min(E[i-1],R[i-1]);
		if( b[i]==1 ) E[i] = min(W[i-1],R[i-1]);
		R[i] = min(W[i-1]+1,min(E[i-1]+1,R[i-1]+1));
	}
	cout << min(W[n-1],min(E[n-1],R[n-1]));
	return 0;
}
